/**
 * 公共常量
 * @date 2023/9/26
 */

import type {DropdownMixedOption} from "naive-ui/es/dropdown/src/interface";
import type {DesktopInterface} from "@/typings/desktop";
import emitter from "@utils/common/Mitt";

/**
 * 月份的中文数字
 */
export const zhNumArr = ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"];

/**
 * 系统导航栏logo下拉列表选项声明
 * @param username
 */
export const getSystemOptions = (username: string): DropdownMixedOption[] => {
  return [
    {
      label: "关于本站",
      key: "system_about",
    },
    {
      type: "divider",
      key: "d1",
    },
    {
      label: "系统偏好设置",
      key: "system_setting",
    },
    {
      label: "应用商店",
      key: "system_store",
    },
    {
      type: "divider",
      key: "d2",
    },
    {
      label: "强制退出...",
      key: "system_task",
    },
    {
      type: "divider",
      key: "d3",
    },
    {
      label: "关机...",
      key: "system_shutdown",
    },
    {
      type: "divider",
      key: "d4",
    },
    {
      label: "锁定屏幕",
      key: EmitNames.LockScreen,
    },
    {
      label: `退出登录“${username}”...`,
      key: "emit-system_logout",
    },
  ];
};

export const deskTopDefaultNavMenus: DesktopInterface.DeskTopNavMenu[] = [
  {
    key: "desktop",
    label: "桌面",
    children: [
      { key: "big_icon", label: "大图标" },
      { key: "min_icon", label: "小图标" },
      { key: "line-1", type: "divider" },
      { key: "align_left", label: "左侧排列" },
      { key: "align_right", label: "右侧排列" },
      { key: "line-2", type: "divider" },
      { key: "wall", label: "更换壁纸..." },
    ],
  },
];

const cb = () => {
  // window.$notification["warning"]({ content: "功能即将上线，敬请期待" });
  window.$notification.create({
    title: "提醒",
    content: "内容",
    duration: 5000, // 不设置不会自动关闭
    meta: "meta",
  });
};

/**
 * 右键菜单项声明定义
 */
export const contextmenuList: DesktopInterface.ContextMenu[] = [
  {
    title: "锁定屏幕...",
    callback: () => {
      emitter.emit(EmitNames.LockScreen, true);
    },
  },
  {
    title: "",
    type: "divider",
  },
  {
    title: "系统偏好设置...",
    callback: cb,
  },
  {
    title: "强制退出...",
    callback: cb,
  },
  {
    title: "",
    type: "divider",
  },
  {
    title: "设置壁纸...",
    callback: cb,
  },
  {
    title: "关于我们.",
    callback: cb,
  },
];

export const EmitNames = {
  // 锁屏
  LockScreen: "emit-lock-screen",
  Launchpad: "emit-launchpad",
  Refresh: "emit-refresh",
  Logout: "emit-system_logout",
  ChangeDesktopNav: "change-desktop-nav",
} as const;

export const AppKeys = {
  SYSTEM_ABOUT: "system_about",
  SYSTEM_FINDER: "system_finder",
  SYSTEM_LAUNCHPAD: "system_launchpad",
} as const;
